package com.lm.activemq.producer;

import com.lm.activemq.config.ActiveMQConfig;
import lombok.RequiredArgsConstructor;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class MessageProducer {

    private final JmsMessagingTemplate jmsMessagingTemplate;

    public void sendQueue(String message) {
        System.out.println("发送 Queue 消息: " + message);
        jmsMessagingTemplate.convertAndSend(ActiveMQConfig.QUEUE_NAME, message);
    }

    public void sendTopic(String message) {
        System.out.println("发送 Topic 消息: " + message);
        jmsMessagingTemplate.convertAndSend(ActiveMQConfig.TOPIC_NAME, message);
    }
}
